﻿using System;
using UnityEngine;

// Token: 0x0200012B RID: 299
public class AnimeParamBlink : MonoBehaviour
{
	// Token: 0x170000C2 RID: 194
	// (get) Token: 0x060006C1 RID: 1729 RVA: 0x0002820C File Offset: 0x0002640C
	// (set) Token: 0x060006C2 RID: 1730 RVA: 0x00028214 File Offset: 0x00026414
	public float LimitMin
	{
		get
		{
			return this.limitMin;
		}
		set
		{
			this.limitMin = value;
			this.UpdateParam();
		}
	}

	// Token: 0x170000C3 RID: 195
	// (get) Token: 0x060006C3 RID: 1731 RVA: 0x00028224 File Offset: 0x00026424
	// (set) Token: 0x060006C4 RID: 1732 RVA: 0x0002822C File Offset: 0x0002642C
	public float LimitMax
	{
		get
		{
			return this.limitMax;
		}
		set
		{
			this.limitMax = value;
			this.UpdateParam();
		}
	}

	// Token: 0x170000C4 RID: 196
	// (get) Token: 0x060006C5 RID: 1733 RVA: 0x0002823C File Offset: 0x0002643C
	// (set) Token: 0x060006C6 RID: 1734 RVA: 0x00028244 File Offset: 0x00026444
	public bool Hold { get; set; }

	// Token: 0x060006C7 RID: 1735 RVA: 0x00028250 File Offset: 0x00026450
	private void Awake()
	{
		this.paramID = Animator.StringToHash(this.paramName);
		this.timer = UnityEngine.Random.Range(this.waitMin, this.waitMax);
		this.blinkEvaluate = 0f;
		this.useCurve = this.normalCurves;
	}

	// Token: 0x060006C8 RID: 1736 RVA: 0x0002829C File Offset: 0x0002649C
	private void Start()
	{
		this.animator.SetFloat(this.paramID, this.limitMax);
	}

	// Token: 0x060006C9 RID: 1737 RVA: 0x000282B8 File Offset: 0x000264B8
	private void Update()
	{
		if (this.Hold)
		{
			this.animator.SetFloat(this.paramID, this.limitMax);
		}
		else if (this.timer > 0f)
		{
			this.timer -= Time.deltaTime;
			if (this.timer <= 0f)
			{
				this.useCurve = ((UnityEngine.Random.Range(0f, 100f) >= this.rareProbability) ? this.normalCurves : this.rareCurves);
				this.blinkEvaluate = 0f;
			}
		}
		else
		{
			float num = 1f;
			if (this.blinkEvaluate < 1f)
			{
				this.blinkEvaluate += Time.deltaTime * this.speed;
				num = this.useCurve.Evaluate(this.blinkEvaluate);
			}
			else
			{
				this.timer = UnityEngine.Random.Range(this.waitMin, this.waitMax);
			}
			num = Mathf.Lerp(this.limitMin, this.limitMax, num);
			this.animator.SetFloat(this.paramID, num);
		}
	}

	// Token: 0x060006CA RID: 1738 RVA: 0x000283E4 File Offset: 0x000265E4
	private void UpdateParam()
	{
		float num = 1f;
		if (this.blinkEvaluate < 1f)
		{
			num = this.useCurve.Evaluate(this.blinkEvaluate);
		}
		num = Mathf.Lerp(this.limitMin, this.limitMax, num);
		this.animator.SetFloat(this.paramID, num);
	}

	// Token: 0x040006A9 RID: 1705
	[SerializeField]
	private Animator animator;

	// Token: 0x040006AA RID: 1706
	[SerializeField]
	private string paramName;

	// Token: 0x040006AB RID: 1707
	[SerializeField]
	private AnimationCurve normalCurves;

	// Token: 0x040006AC RID: 1708
	[SerializeField]
	private AnimationCurve rareCurves;

	// Token: 0x040006AD RID: 1709
	[SerializeField]
	private float rareProbability = 10f;

	// Token: 0x040006AE RID: 1710
	[SerializeField]
	private float speed = 1f;

	// Token: 0x040006AF RID: 1711
	[SerializeField]
	private float waitMin = 2f;

	// Token: 0x040006B0 RID: 1712
	[SerializeField]
	private float waitMax = 5f;

	// Token: 0x040006B1 RID: 1713
	private float timer;

	// Token: 0x040006B2 RID: 1714
	private float blinkEvaluate;

	// Token: 0x040006B3 RID: 1715
	private AnimationCurve useCurve;

	// Token: 0x040006B4 RID: 1716
	private int paramID;

	// Token: 0x040006B5 RID: 1717
	private float limitMin;

	// Token: 0x040006B6 RID: 1718
	private float limitMax = 1f;
}
